package 斗地主版本1;

import java.util.ArrayList;
import java.util.Collections;

public class QuasiShampooOne {

    //准备牌盒
    static ArrayList<String> list=new ArrayList<>();

    //准备四个集合
    //玩家一
    static ArrayList<String> gamerOne=new ArrayList<>();
    //玩家二
    static ArrayList<String> gamerTwo=new ArrayList<>();
    //玩家三
    static ArrayList<String> gamerThree=new ArrayList<>();
    //底牌
    static ArrayList<String> Cards=new ArrayList<>();
    //利用键与值


    //准备牌
    static {
        //准备牌的花色
        String[] color={"♦","♣","♥","♠"};
        //准备牌的数字
        String[] number={"3","4","5","6","7","8","9","10","J","Q","K","A","2"};

        //将牌调整为最终样式
        /*
        s:为数字
        s1:为花色
         */
        for (String s : number) {
            for (String s1 :color ) {
                list.add(s+s1);
            }
        }
        list.add("大王");
        list.add("小王");

        System.out.println(list);

    }
    public QuasiShampooOne(){
        //洗牌
        Collections.shuffle(list);
        //System.out.println(list);

        //发牌
        deal();

        //看牌
        Look("底牌",Cards);
        Look("孙权",gamerOne);
        Look("刘备",gamerTwo);
        Look("曹操",gamerThree);

    }
    public static void Look(String name,ArrayList<String> list){
        System.out.print(name+":");
        for (String s : list) {
            System.out.print(s+" ");
        }
        System.out.println();
    }

    //发牌
    public static void deal(){

        for (int i = 0; i < list.size(); i++) {
            //获取牌
            String index = list.get(i);
            //判断
            if (i<=2){
                //底牌
                Cards.add(index);
                continue;
            }

            //利用取余判断发给那位玩家
            int number=i%3;
            /*
            余数为0：发给玩家一
            余数为1：发给玩家二
            余数为2：发给玩家三
             */
            if(number==0){
                gamerOne.add(index);
            }else if(number==1){
                gamerTwo.add(index);
            }else if(number==2){
                gamerThree.add(index);
            }
        }
    }


}
